/**************************************************************************
File:        laser.h
Description:

Copyright:   (C) 2001-2012 by ZJ Laczik
Email:       Zsolt.Laczik@eng.ox.ac.uk
****************************************************************************
Change log:
   begin      Sun Mar 18 2001
   15/2/2012	QT4 update
***************************************************************************/

#ifndef LASER_H
#define LASER_H

#include <qwidget.h>
#include <qobject.h>

#include <unistd.h>
#include <sys/io.h>
#include <sys/time.h>

class Laser : public QObject  {
    Q_OBJECT
public:
    Laser(QWidget *parent=0);
    ~Laser();
public slots:
    void Stop();
    void Fire();
    void Burst();
    void Test() {
        ContFire();
    };
    void ContFire();
    void SetNPulses(int n=10);
    void SetRepRate(int r=10);
    void SetTriggerDelay(long int r=0);
    void CheckInterlock();
signals:
    void StatusMsg(const QString & message, bool);
    void Running(bool state);
    void Shoot(bool & success);
    void NPulsesChanged(int n);
    void RepRateChanged(int r);
    void TriggerDelayChanged(long int r);
    void sigStop();
private:
    void Trigger();
    bool mStopFlag;
    bool mShutterOpen;
    int mNPulses;
    int mRepRate;
    long int mTriggerDelay;

    void usec_delay(long int usecs);
    void init_usec_delay();

    bool InterlockOK();
    void WarningSignOff();
    void WarningSignOn();
    void TriggerPulse() ;
    long int delay_cal;
    long int delay_res;
    unsigned char portvalue;
};

#endif
